home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 1
/
Precision Software Applications Silver Collection Volume One (PSM) (1993).iso
/
tutor
/
dbase1iv.exe
/
DB4LESS4.ZIP
/
TRANPROC.PRG
< prev
next >
Wrap
Text File
|
1989-01-04
|
1KB
|
50 lines
* TRANPROC.PRG
* Example of Transaction Processing
*
* Also: Procedure, On Error, LKSYS(), Set Reprocess
SET REPROCESS TO 10 && Try network locks 10 times before error
ON ERROR DO errproc && Procedure errproc handles ROLLBACK
fileok=.T.
USE emp
IF fileok
BEGIN TRANSACTION && Begin transaction logging
REPLACE ALL lname WITH 'BRUCE' FOR lname = 'Bruce' && ERROR IF LOCKED
LIST LNAME
WAIT
END TRANSACTION && End transaction logging and update
LIST LNAME
ENDIF
ON ERROR && Reset error handling
RETURN
PROCEDURE ERRPROC
MANS='N'
CLEAR
DO CASE
CASE ERROR() = 108 && File locked
otheruser=IIF(LEN(LKSYS(2))=0,'another',LKSYS(2)) && if no user name
WAIT 'File is locked by '+TRIM(otheruser)+'. Press any key.'
fileok=.F.
RETURN
CASE ERROR() = 109 && Record locked
otheruser=IIF(LEN(LKSYS(2))=0,'another',LKSYS(2)) && if no user name
WAIT 'Record is locked by '+TRIM(otheruser)+'. Press any key.'
OTHERWISE && Any other error
@ 1,0 SAY MESSAGE()+' '+STR(ERROR(),4)
ENDCASE
@ 2,0 SAY 'DO YOU WISH TO RETRY? ' GET MANS FUNCTION '!'
READ
IF MANS='Y' && Retry
CLEAR
RETRY
ELSE && Rollback
CLEAR
@ 0,0 SAY 'ROLLING BACK YOUR CURRENT TRANSACTIONS...'
ROLLBACK
ENDIF
RETURN
* EOP: TRANPROC.PRG